/*
 * XTabbedPaneTab.java
 * 
 * Copyright (c) 2006 - 2007
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.xfc.components;

import javax.swing.Icon;
import javax.swing.JComponent;

import org.xfc.model.XObject;

// TODO: separate this into an interface and a default implementation?


/**
 * 
 * 
 * @author Devon Carew
 */
public class XTabbedPaneTab
	extends XObject
{
	
	
	/**
	 * Create a new tabbed pane tab.
	 */
	public XTabbedPaneTab()
	{
		
	}
	
	/**
	 * Create a new tabbed pane tab.
	 * 
	 * @param title
	 */
	public XTabbedPaneTab(String title)
	{
		setTitle(title);
	}

	/**
	 * Create a new tabbed pane tab.
	 * 
	 * @param title
	 * @param component
	 */
	public XTabbedPaneTab(String title, JComponent component)
	{
		setTitle(title);
		setComponent(component);
	}
	
	/**
	 * Create a new tabbed pane tab.
	 * 
	 * @param title
	 * @param icon
	 * @param component
	 */
	public XTabbedPaneTab(String title, Icon icon, JComponent component)
	{
		setTitle(title);
		setIcon(icon);
		setComponent(component);
	}
	
	public Icon getIcon()
	{
		return (Icon)getValue("icon");
	}
	
	public void setIcon(Icon icon)
	{
		setValue("icon", icon);
	}
	
	public String getTitle()
	{
		return (String)getValue("title");
	}
	
	public void setTitle(String title)
	{
		setValue("title", title);
	}
	
	public String getToolTipText()
	{
		return (String)getValue("toolTipText");
	}
	
	public void setToolTipText(String toolTipText)
	{
		setValue("toolTipText", toolTipText);
	}
	
	public void setComponent(JComponent component)
	{
		setValue("component", component);
	}
	
	public JComponent getComponent()
	{
		return (JComponent)getValue("component");
	}
	
	/**
	 * Returns whether this tab is a closeable tab.
	 * 
	 * @return Returns whether this tab is a closeable tab.
	 */
	public boolean isCloseableTab()
	{
		return getValueAsBoolean("closeableTab");
	}
	
	/**
	 * @param closeable
	 */
	public void setCloseableTab(boolean closeable)
	{
		setValue("closeableTab", closeable);
	}
	
	/**
	 * Returns whether this tab can close at this particular time. This gives
	 * the application a chance to dynamically decide whether a tab can close.
	 * An example of this is querying the user to save changes / discard changes
	 * or cancel a close operation.
	 * 
	 * @return Returns whether this tab can close at this particular time.
	 */
	public boolean canClose()
	{
		return true;
	}
	
}
